<?php
if (!defined('INDEX')) exit;
require("common/functions_jcas_modules.php");

// ACTIONS
echo home_update_note();

if($show_content)
{
	// Admin note
	$admin_note = $DB->fetch_array($DB->query('SELECT admin_note FROM '.$tbl['admin_accounts'].' WHERE id="'.$admin_session['admin_id'].'"'));
	
	// Admin logs
	$q_log = $DB->query('SELECT * FROM '.$tbl['admin_log'].' WHERE admin_id="'.$admin_session['admin_id'].'" ORDER BY created_time DESC LIMIT 0,12');
	$num_log = $DB->num_rows($q_log);
	?>
	<table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0">
				  <tr>
					 <td >&nbsp;</td>
				  </tr>
				  <tr>
					 <td bgcolor="#FFFFFF" ><table width="100%"  border="0" cellspacing="0" cellpadding="0">
						<tr>
						  <td valign="top" class="headtd"><?php echo $lang['admin_home']?></td>
					   </tr>
						<tr>
						  <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
							<tr>
								<td width="40%" valign="top"><table width="100%"  border="0" cellspacing="0" cellpadding="1">
	
								  <tr>
									<td class="subheadtd"><strong><?php echo $lang['admin_info']?></strong></td>
								  </tr>
								  <tr>
									<td ><table width="100%" border="0" cellspacing="0" cellpadding="2">
										<tr>
										  <td class="datatd">&#8226 <strong><?php echo $lang['admin_username']?></strong> : <font color="#CC0000"><strong><?php echo $admin_session['admin_user']?></strong></font></td>
										</tr>
										
										<tr>
										  <td class="datatd">&#8226 <strong><?php echo $lang['user_ip']?></strong>: <font color="#CC0000"><?php echo $_SERVER['REMOTE_ADDR']?> </font></td>
										</tr>
										<tr>
										  <td class="datatd">&#8226 <strong><?php echo $lang['last_login']?></strong>: <font color="#CC0000"><?php echo show_date($cfg['date_format'],timestamp($admin_session['last_login']))?></font></td>
										</tr>
										<tr>
										  <td class="row1td" height="25">
										  <input type="button" class="button" value="<?php echo $lang['btn_change_pwd']?>" onclick="showModalDialog('popups/change_pwd.html', window, 'resizable: no; help: no; status: no; scroll: no; ')" />
										  <input type="button" class="button" value="<?php echo $lang['btn_logout']?>" style="color:#990000" onClick="ask('login.php?act=logout','<?php echo $lang['js_confirm_logout']?>');" />									  </td>
										</tr>
									</table></td>
								  </tr>
								  
								</table></td>
								<td width="60%" valign="top"><table width="100%"  border="0" cellspacing="0" cellpadding="1">
								<form id="frm_note" name="frm_note" method="post" action="">
								  <tr>
									<td class="subheadtd"><strong><?php echo $lang['admin_note']?></strong></td>
								  </tr>
								  <tr>
									<td class="menu2td">
									  <textarea name="admin_note" style="width:100%; height:48px"><?php 
									  if($admin_session['admin_note']) echo $admin_note['admin_note'];
									  else echo $lang['default_note'];
									  ?></textarea>                                </td>
								  </tr>
								  <tr>
									<td align="center" class="menu2td"><input type="submit" class="button" name="update_note" value="<?php echo $lang['btn_save']?>" /></td>
								  </tr>
								  <input type="hidden" name="session_id" value="<?php echo session_id()?>" />
								  </form>
								</table></td>
							</tr>
							  <tr>
								<td colspan="2"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
								  <form id="form1" name="form1" method="post" action="">
									<tr>
									  <td class="subheadtd"><strong><?php echo $lang['action_history']?></strong></td>
									</tr>
									<tr>
									  <td ><table width="100%" border="0" cellspacing="0" cellpadding="1">
										<tr>
										  <td width="20" align="center" class="row2td"><strong><?php echo $lang['order']?></strong></td>
										  <td align="center" class="row1td"><strong><?php echo $lang['operation']?></strong></td>
										  <td width="120" align="center" class="row1td"><strong><?php echo $lang['database_name']?></strong> </td>
										  <td width="100" align="center" class="row1td"><strong><?php echo $lang['time']?></strong></td>
										  <td width="100" align="center" class="row1td"><strong><?php echo $lang['user_ip']?></strong></td>
										</tr>
										<?php
										
										if($num_log)
										{
											$no = 0;
											for($x=0;$x<$num_log;$x++)
											{
												
												$no += 1;
												$log = $DB->result_array($q_log,$x,'title,module,db_table,admin_ip,created_time');
											?>
											<tr height="18">
											  <td align="right" class="datatd"><?php echo $no?>.</td>
											  <td class="datatd"><?php echo $log['title']?></td>
											  <td align="right" class="datatd"><font color="#CC0000"><?php echo $log['db_table']?></font></td>
											  <td align="right" class="datatd"><font class="info"><?php echo show_date($cfg['date_format'],timestamp($log['created_time']))?></font></td>
											  <td align="right" class="datatd"><font color="#3300FF"><?php echo $log['admin_ip']?></font></td>
											</tr>
											<?php
											}
										}
										else
										{
											?>
											<tr>
											  <td colspan="10" align="center" class="datatd"><font class="info"><?php echo $lang['no_requested_data']?></font></td>
											</tr>
											<?php
										}
										?>
									  </table></td>
									</tr>
								  </form>
								</table></td>
							  </tr>
							</table></td>
						</tr>
					 </table></td>
				  </tr>
	</table>
<?php
}// end show_content
$_GET["p"] = false;
?>